package com.chen.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.chen.entity.ExamPlan;
import com.chen.vo.ExamPlanVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 考试计划Mapper
 */
public interface ExamPlanMapper extends BaseMapper<ExamPlan> {

    /**
     * 根据班级id和年级id查询考试信息
     * @param classId 班级id
     * @param gradeId 年级id
     * @return
     */
    public List<ExamPlanVO> getStudentWillExam(@Param("classId") Integer classId, @Param("gradeId") Integer gradeId);

    /**
     * 待考记录
     * @return
     */
    public List<ExamPlanVO> getExamPlanList();

    public ExamPlanVO getExamPlanById(Integer id);

    /**
     * 更具科目查看考试计划个数
     * @param courseId
     * @return
     */
    default Long findCountByCourseId(Integer courseId) {
        Wrapper<ExamPlan> queryWrapper = Wrappers.lambdaQuery(ExamPlan.class).eq(ExamPlan::getCourseId, courseId);
        return selectCount(queryWrapper);
    }

    /**
     * 根据试卷id删除
     * @param examPaperId
     * @return
     */
    default Integer deleteByExamPaperId(Integer examPaperId) {
        Wrapper<ExamPlan> updateWrapper = Wrappers.lambdaUpdate(ExamPlan.class).eq(ExamPlan::getExamPaperId, examPaperId);
        return delete(updateWrapper);
    }

    /**
     * 删除过期的考试计划
     * @return
     */
    Integer deleteExpirePlan();

}
